<{include file="public/header.html"}> 
	<header class="title title-border-sm bj-white">
            <a href="<{eval url('account/index')}>" class="icon-return iconfont title-left title-top col-red">&#xe604;</a>
		<h1 class="text-center name">申请提现</h1>
	</header>
<div class="coin-page">
	<ul class="coin-detail" style="border-top: 0;">
		<li class="active" onclick="window.location.href=$(this).attr('data-href');" data-href="<{eval url('user/cash')}>?type=1" style="width:45%">溜溜币提现</li>
		<li onclick="window.location.href=$(this).attr('data-href');" data-href="<{eval url('user/cash')}>?type=2" style="width:45%">社区溜珠提现</li>
	</ul>
</div>
	<form id="cash-form" class="plr15 mt50" data-href="<{eval url('user/do_cash')}>" onsubmit="return false;">
		<div class="security">
			<ul class="mt50">
				<li class="border-bottom-sm">
					<a href="javascript:;" class="f-cb plr5">
						<p class="fl">溜溜币余额</p>
						<p class="fr"><{$liubi_balance}>（约<span style="color:#fd8686;"><{$balance}>.00</span>元）</p>
					</a>
				</li>
				<li class="border-bottom-sm">
					<a href="javascript:;" class="f-cb plr5" id="type_on">
						<p class="fl">提现方式</p>
						<font class="iconfont fr ml5 col-greyccc">&#xe630;</font>
						<i class="fr col-grey999" id="type_on_name">请选择</i>
						<input type="hidden" name="type" id="type" data-validate="type" value="0"/>
					</a>
				</li>
				<li class="border-bottom-sm">
					<a href="javascript:;" class="f-cb plr5" id="type_acc_on">
						<p class="fl">收款帐号</p>
						<font class="iconfont fr ml5 col-greyccc">&#xe630;</font>
						<i class="fr col-grey999" id="type_acc_name">请选择</i>
						<input type="hidden" name="accountId" id="type_acc" data-validate="type_acc" value=""/>
					</a>
				</li>
			</ul>

			<div class="input-group input-group-tip">
				<p style="color:#333;">提现金额</p>
				<input type="text" name="cashValue" id="cashAmount" data-validate="cashAmount" placeholder="输入金额，1的整倍数	"/>
			</div>
			<div class="input-group input-group-tip">
				<p style="color:#333;">交易密码</p>
				<input type="password" name="payPass" id="cashPaypass" data-validate="cashPaypass" placeholder="输入交易密码"/>
				<p style="right:5px;top:15px;"><a href="<{eval url('account/paypass')}>" style="color:#999;">忘记密码？</a></p>
			</div>
			<input type="submit" id="form-modify-btn" class="btn btn-yes mt10" value="确认提现">
		</div>
	</form>

<div class="public-field-bj publick-jq2" id="case_type" >
	<div class="public-field-phone w100" id="case_type_cont" style="bottom: 5px;">
		<div class="plr15">
			<ul class="bj-white">
				<li data-type="0">提现方式</li>
				<li data-type="1" data-name="支付宝" data-min="<{$withdraw_min_alipay}>">支付宝</li>
				<li data-type="2" data-name="银行卡" data-min="<{$withdraw_min_bank}>">银行卡</li>
			</ul>
			<button class="btn bj-white mt5 close-jq _close" style="border-radius: 12px;">取消</button>
		</div>
	</div>
</div>
<div class="public-field-bj publick-jq2 case_acc" id="case_acc_1">
	<div class="public-field-phone w100 case_acc_cont" id="case_acc_cont_1" style="bottom: 5px;">
		<div class="plr15">
			<ul class="bj-white">
				<li data-type="0">支付宝帐号</li>
				<{if $alipays}>
				<{foreach from=$alipays item=val key=key}>
				<li data-id="<{$val['id']}>" data-name="<{$val['account']}>"><{$val['name']}>(<{$val['account']}>)</li>
				<{/foreach}>
				<{else}>
				<li>您还未绑定支付宝！<a href="<{eval url('user/cash_bind')}>?type=1">立即绑定>></a></li>
				<{/if}>
			</ul>
			<button class="btn bj-white mt5 close-jq _close">取消</button>
		</div>
	</div>
</div>
<div class="public-field-bj publick-jq2 case_acc" id="case_acc_2">
	<div class="public-field-phone w100 case_acc_cont" id="case_acc_cont_2" style="bottom: 5px;">
		<div class="plr15">
			<ul class="bj-white">
				<li data-type="0">银行帐号</li>
				<{if $banks}>
				<{foreach from=$banks item=val key=key}>
				<li data-id="<{$val['id']}>" data-name="<{$val['account']}>"><{$val['name']}>(<{$val['account']}>)</li>
				<{/foreach}>
				<{else}>
				<li>您还未绑定银行卡！<a href="<{eval url('user/cash_bind')}>?type=2">立即绑定>></a></li>
				<{/if}>
			</ul>
			<button class="btn bj-white mt5 close-jq _close">取消</button>
		</div>
	</div>
</div>
<script type="text/javascript">
	$("#type_on").click(function () {
        $("#case_type").stop().fadeIn();
    });
    $("#case_type").click(function () {
        $("#case_type").stop().fadeOut();
    });
    $("#case_type").children().find('ul li').click(function(){
        var _this = $(this),
            _type = _this.attr("data-type"),
			_min=_this.attr("data-min"),
        	_name = _this.attr("data-name");

        if(!_is_login()){return;}
        if(_type == 0){return;}else{$("#cashAmount").attr("placeholder","最低提现"+_min+"元");}
        $("#type_acc_name").html("请选择");
		$("#type_on_name").html(_name);
        $("#type").val(_type);
    });

    $("#type_acc_on").click(function () {
        fadeinH();
    });
    $(".case_acc").click(function () {
        fadeoutH($);
    });
    $(".case_acc_cont").children().find('ul li').click(function(){
        var _this = $(this),
            _id = _this.attr("data-id"),
            _name = _this.attr("data-name");

        $("#type_acc_name").html(_name);
        $("#type_acc").val(_id);
    });
    function fadeinH() {
        var type = $("#type").val();
        if(type==0){
            $.mvalidateTip("请先选择提现方式");
		}else{
            $("#case_acc_"+type).stop().fadeIn();
		}


    }
    function fadeoutH() {
        var type = $("#type").val();
        if(type==0){
            $.mvalidateTip("请先选择提现方式");
        }else{
            $("#case_acc_"+type).stop().fadeOut();
        }

    }

var send_flag = true;
$(function(){
    var check_flag = true,check_count = 0;
    $.mvalidateExtend({
        type:{
			required : true,
			each:function(){

			},
			descriptions:{
				required : '<div class="field-invalidmsg">请选择提现方式</div>',
			}
		},
        type_acc:{
            required : true,
            each:function(){

            },
            descriptions:{
                required : '<div class="field-invalidmsg">请选择提现帐号</div>',
            }
        },
        cashAmount:{
            required : true,   
            pattern : /(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/,
            each:function(){

            },
            descriptions:{
                required : '<div class="field-invalidmsg">请输入提现金额</div>',
                pattern : '<div class="field-invalidmsg">金额的输入格式不正确</div>',
            }
        },
        cashPaypass:{
            required : true,
            each:function(){

            },
            descriptions:{
                required : '<div class="field-invalidmsg">请输入交易密码</div>',
            }
        }
    });
     $("#cash-form").mvalidate({
        type:1,
        onKeyup:true,
        sendForm:true,
        firstInvalidFocus:false,
        descriptions: {},
        valid:function(event,options){
            add_check_oper_listener();
            var url = $("#cash-form").attr("data-href");
            check_flag = false;
            
            $("#form-modify-btn").val("提交中...");
            $.ajax({
                type: "POST",
                url: url,
                async:true, 
                data: $("#cash-form").serialize(),
                success: function(resp) {
                    resp = $.parseJSON(resp);

                    if(resp.reqStatus){
                        $.mvalidateTip("提交成功");

                        setTimeout(function () {
                            location.href = "/account/withdraw.html";
                        }, 2000);
                    }else{
                        cancel_check_oper_listener();
                        $("#form-modify-btn").val("重新提交");
                        $.mvalidateTip(resp.errorMsg);
                        return false;
                    }
                }
            });
        },
        invalid:function(event, status, options){
            //点击提交按钮时,表单未通过验证触发函数
        },
        eachField:function(event,status,options){
            //点击提交按钮时,表单每个输入域触发这个函数 this 执向当前表单输入域，是jquery对象
        },
        eachValidField:function(val){},
        eachInvalidField:function(event, status, options){},
    })
    
    function add_check_oper_listener(){
        if(check_count == 2){
            check_count = 0;
            $.mvalidateTip("操作过于频繁");return false;
        }
        if(!check_flag){
            check_count ++;
            $.mvalidateTip("正在处理操作");return false;
        }
    };
    function cancel_check_oper_listener(){
        check_count = 0;
        check_flag = true;
    }

});

</script>
<{include file="public/footer.html"}> 